#ifndef THREEDMATRIX__H
#define THREEDMATRIX__H

#include <vector>
using namespace std;
class Point;

class Matrix3D
{
public:
	Matrix3D(unsigned nRows = 4,unsigned nCols = 4,bool bZeroMatrix = false);
	Matrix3D(const Matrix3D& m);
	~Matrix3D();
	const Matrix3D& operator=(const Matrix3D& m);
	Matrix3D operator-() const;
	Matrix3D operator-(const Matrix3D &mat) const;
	void operator+=(const Matrix3D &mat);
	
	Matrix3D operator+(const Matrix3D &mat);
	double* operator[](unsigned unIndex);
	const double* operator[](unsigned unIndex) const;
	Matrix3D operator*(const Matrix3D& m) const;
	Matrix3D Matrix3D::operator *(double dbConstant);
	void Matrix3D::operator *=(double dbConstant);
	static Matrix3D ScaleMatrix(double dbFactor);
	static Matrix3D RotateMatrix(double dbAngle,int nAxis);
	static Matrix3D TranslateMatrix(double dbTx,double dbTy,double dbTz);
	static Matrix3D TranslateMatrix(double dbT,int nAxis);
	
	// should only work when both current object and mat object are vectors!
	// note that the homogenous coordinate returned is always 1!
	Matrix3D CrossProduct (const Matrix3D &vector) const;

	void Normalize(double dbToSize);
	bool IsEmpty();

	static int roundInt(double d);

private:
	//vector< vector<double> > m_values;
	void clear();
	void CopyMatrix(const Matrix3D& m);
	double** m_values;
	unsigned m_nRows;
	unsigned m_nCols;
};


#endif